home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / FTP / Mirror2.3 / pkgs_to_mmin < prev    next >
Encoding:
Text File  |  1994-01-31  |  2.2 KB  |  106 lines

  1. #!/usr/bin/perl
  2. # Convert a load of package files into mm input
  3. # Presumes files are of the form:
  4. # package=thingy
  5. #   field=value
  6. #   field=value
  7. #   ...
  8. #
  9. # pkgs_to_mmin [-y min_restart_last_ok] [-n min_restart_last_notok] [packages]
  10. #
  11. # By Lee McLoughlin <lmjm@doc.ic.ac.uk>
  12. #  You can do what you like with this except claim that you wrote it or
  13. #  give copies with changes not approved by Lee.  Neither Lee nor any other
  14. #  organisation can be held liable for any problems caused by the use or
  15. #  storage of this package.
  16. #
  17. # $Id: pkgs_to_mmin,v 2.4 1994/01/28 17:59:02 lmjm Exp lmjm $
  18. # $Log: pkgs_to_mmin,v $
  19. # Revision 2.4  1994/01/28  17:59:02  lmjm
  20. # Made eof handling work!
  21. # Use site= from package not filename.
  22. #
  23. # Revision 2.3  1994/01/18  21:58:31  lmjm
  24. # Correct end of file handling.
  25. #
  26. # Revision 2.2  1993/12/14  11:09:22  lmjm
  27. # Minor corrections.
  28. #
  29. # Revision 2.1  1993/06/28  15:22:32  lmjm
  30. # Full 2.1 release
  31. #
  32. # Revision 1.1  1993/06/22  19:52:46  lmjm
  33. # Initial revision
  34. #
  35. #
  36.  
  37. # Allow a day (more or less) before trying a site again.
  38.  
  39. $min_restart_last_ok = 20;
  40. $min_restart_last_notok = 20;
  41.  
  42. while( $#ARGV >= 0 ){
  43.     local( $arg ) = shift;
  44.  
  45.     # only bother with -flag's
  46.     if( $arg !~ /^-/ ){
  47.         unshift( ARGV, $arg );
  48.         last;
  49.     }
  50.  
  51.     if( $arg =~ /-y(.*)$/ ){
  52.         local( $val ) = $1;
  53.         if( length( $val ) == 0 ){
  54.             # must be -y space number
  55.             $val = shift;
  56.         }
  57.         $min_restart_last_ok = $val;
  58.     }
  59.     elsif( $arg =~ /-n(.*)$/ ){
  60.         local( $val ) = $1;
  61.         if( length( $val ) == 0 ){
  62.             # must be -n space number
  63.             $val = shift;
  64.         }
  65.         $min_restart_last_notok = $val;
  66.     }
  67. }
  68.  
  69. $package = '';
  70. while( <> ){
  71.     if( eof(ARGV) || /^\s*$/ ){
  72.         &pr();
  73.     }
  74.     chop;
  75.     if( /^\s*package\s*=(.*)/ ){
  76.         if( $package ){
  77.             &pr();
  78.         }
  79.         $package = $1;
  80.         $package =~ s/^\s*//;
  81.         $package =~ s/\s*$//;
  82.     }
  83.     elsif( /^\s*site\s*=(.*)/ ){
  84.         $site = $1;
  85.     }
  86.     elsif( /^\s*skip=/ ){
  87.         $package = '';
  88.     }
  89.     # Ignore everthing else as mirror config files are
  90.     # too free format to parse easily.
  91. }
  92. exit;
  93.  
  94. sub pr
  95. {
  96.     return unless $package && $site;
  97.     $file = $ARGV;
  98.     $file =~ s,.*/,,;
  99.     if( $file !~ /^$site$/ ){
  100.         warn "File is $file but site is $site\n";
  101.     }
  102.  
  103.     print "$file:$package $min_restart_last_ok $min_restart_last_notok\n";
  104.     $package = '';
  105. }
  106.